package com.ss.android.article.browser.view.a;

import android.support.v7.widget.RecyclerView.Adapter;
import android.support.v7.widget.RecyclerView.ViewHolder;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.ss.android.image.AsyncImageView;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

public final class b extends Adapter {
    public interface a {
        void a(int arg1);
    }

    final class b$b extends ViewHolder {
        AsyncImageView a;
        TextView b;

        public b$b(View arg2, com.ss.android.article.browser.view.a.b.a arg3) {
            super(arg2);
            this.a = arg2.findViewById(com.ss.android.article.browser.R.id.icon);
            this.b = arg2.findViewById(com.ss.android.article.browser.R.id.xd);
            if(arg3 != null) {
                arg2.setOnClickListener(new c(this, arg3));
            }
        }
    }

    public List<com.ss.android.article.browser.website.NavigationBean> a;
    public com.ss.android.article.browser.view.a.b.a b;

    public b() {
        this.a = new ArrayList();
    }

    public final void a(List arg2) {
        if(arg2 != null && !arg2.isEmpty()) {
            this.a.clear();
            this.a.addAll(((Collection)arg2));
            this.notifyDataSetChanged();
        }
    }

    public final int getItemCount() {
        int v0 = this.a == null ? 0 : this.a.size();
        return v0;
    }

    public final void onBindViewHolder(ViewHolder arg4, int arg5) {
        String v1 = this.a.get(arg5).icon_url;
        String v2 = this.a.get(arg5).screen_name;
        if(!TextUtils.isEmpty(((CharSequence)v1))) {
            if(v1.startsWith("http")) {
                ((b$b)arg4).a.setUrl(this.a.get(arg5).icon_url);
            }
            else if(TextUtils.isDigitsOnly(((CharSequence)v1))) {
                ((b$b)arg4).a.setImageResource(Integer.parseInt(v1));
            }
        }

        if(!TextUtils.isDigitsOnly(((CharSequence)v2)) || v2.length() <= 8) {
            ((b$b)arg4).b.setText(this.a.get(arg5).screen_name);
        }
        else {
            ((b$b)arg4).b.setText(Integer.parseInt(v2));
        }
    }

    public final ViewHolder onCreateViewHolder(ViewGroup arg5, int arg6) {
        return new b$b(LayoutInflater.from(arg5.getContext()).inflate(com.ss.android.article.browser.R.layout.em, arg5, false), this.b);
    }
}

